var app = angular.module('stockgroupList', []);
app.controller('listController', function ($scope,$http) {
    getData();
    function getData() {
        $http.post("../stockgroup/index",{
            params: {
                "queryStr":$scope.queryStr
            }
        }).then(function (result) {
            result = result?result.data.result:[];
            //偶数位置空，迭代页面空tr
            for(var i = 0;i<result.length;i++){
                if(i<result.length-1)
                    result.splice(i+1, 0, null);
                i++
            }
            // console.log(result)
            $scope.datas = result;
        });
    };


    $scope.toDetail = function(item) {
        location.href="../stockgroup/detail?groupId="+item.rowId;
    };
});
app.filter('getRealPercent',function(){
    return function(val,importPrice) {
        var realRate = getRealRate(importPrice, val);
        return toDecimal(realRate) + "%";
    }
    function getRealRate(importPrice, realPrice) {
        return (realPrice - importPrice) * 100 / importPrice
    };

    function toDecimal(x) {
        var f = parseFloat(x);
        if (isNaN(f)) {
            return;
        }
        f = Math.round(x * 100) / 100;
        return f;
    };
})
